package org.myy.learn.hot.finish.双指针;

public class 盛最多水的容器 {
    public int maxArea(int[] height) {
        int n = height.length;
        int l = 0, r = n - 1, maxArea = 0;
        while (l < r){
            int area = Math.min(height[l], height[r])*(r-l);
            maxArea = Math.max(area, maxArea);
            if (height[l] > height[r]){   //ToDo 先计算，后移动
                r--;
            } else {
                l++;
            }
        }
        return maxArea;
    }
}
